home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / WWIV Mods / WWIVMOD.ZIP / TOP10.MOD < prev    next >
Encoding:
Text File  |  1993-08-10  |  8.8 KB  |  284 lines

  1. Tue Jan 26 04:00:15 1993
  2.  
  3. ┌────────────────────────────────────────────────────────────────────────────┐
  4. │ Mod Name: Top10 .MOD       Mod Authors: Sledgehammer 1@4654 WWIVnet AC     │
  5. │ Difficulty: Easy                  Date: January 21,1993                    │
  6. │ WWIV Version: 4.22  - but should work on just about any... once you find   │
  7. │               where it's supposed to go in bbs.c                           │
  8. │ Files Affected: bbs.c                                                      │
  9. │ Description: This mod will print out top 10 leachers, posters, uploaders   │
  10. │              and also the users who have spent the most time online.       │
  11. └────────────────────────────────────────────────────────────────────────────┘
  12. Discalimer:   If you do regular BACK UPS you won't ever have problems.  But if 
  13.               do email me and I will help you the best I can.  The mod works   
  14.             perfect with my bbs...
  15.  
  16.  
  17. STEP 1:
  18.  
  19. [PAUSE]       Open up BBS.c and add the followong void just before void mainmenu.
  20.  
  21.  
  22. void top_ten_lists()
  23. {
  24.     userrec u;
  25.     int i,i1,stop,num_users,ok,j;
  26.  
  27.     int             low_posts_on_list,
  28.                     low_logons_on_list,
  29.                     store_int,
  30.                     posts_per_user[10],
  31.                     logons_per_user[10],
  32.                     flag,
  33.                     last;
  34.  
  35.     unsigned long   up_k_per_user[10],
  36.                     dn_k_per_user[10],
  37.                     store_lng;
  38.  
  39.     float           timeon_per_user[10],
  40.                     store_flt;
  41.  
  42.     char s[5][10][31],
  43. [PAUSE]                ch,
  44.          store_chr[31];
  45.  
  46.     for (i = 0; i < 10; i++) {
  47.         posts_per_user[i]  = 0;
  48.         logons_per_user[i] = 0;
  49.         up_k_per_user[i]   = 0;
  50.         dn_k_per_user[i]   = 0;
  51.         timeon_per_user[i] = 0;
  52.     }
  53.     num_users = number_userrecs();
  54.     npr("%2d Total Users",num_users);
  55.     ok = 0;
  56.  
  57. /* Initialize Variables with Default Values */
  58.  
  59.     for (i = 0; i < 5; i++)
  60.         for (i1 = 0; i1 < 10; i1++)
  61.             strcpy(s[i][i1], "None");
  62.  
  63. /* Get the 10 Highest Values From the Userlists */
  64.  
  65.     for( i=1; i<=num_users; i++ )
  66.     {
  67. [PAUSE]               read_user( i, &u );
  68.         stop = posts_per_user[0];
  69.         j = 0;
  70.         for( i1=1; i1<10; i1++ )
  71.             if( posts_per_user[i1] < stop )
  72.             {
  73.                 j = i1;
  74.                 stop = posts_per_user[i1];
  75.             }
  76.         if( u.msgpost > stop )
  77.         {
  78.             posts_per_user[j] = u.msgpost;
  79.             strcpy( s[0][j], nam(&u, i ) );
  80.         }
  81.         stop = logons_per_user[0];
  82.         j = 0;
  83.         for( i1=1; i1<10; i1++ )
  84.             if( logons_per_user[i1] < stop )
  85.             {
  86.                 j = i1;
  87.                 stop = logons_per_user[i1];
  88.             }
  89.         if( u.logons > stop )
  90.         {
  91. [PAUSE]                   logons_per_user[j] = u.logons;
  92.             strcpy( s[1][j], nam(&u, i ) );
  93.         }
  94.         store_lng = up_k_per_user[0];
  95.         j = 0;
  96.         for( i1=1; i1<10; i1++ )
  97.             if( up_k_per_user[i1] < store_lng )
  98.             {
  99.                 j = i1;
  100.                 store_lng = up_k_per_user[i1];
  101.             }
  102.         if( u.uk > store_lng )
  103.         {
  104.             up_k_per_user[j] = u.uk;
  105.             strcpy( s[2][j], nam(&u, i ) );
  106.         }
  107.         store_lng = dn_k_per_user[0];
  108.         j = 0;
  109.         for( i1=1; i1<10; i1++ )
  110.             if( dn_k_per_user[i1] < store_lng )
  111.             {
  112.                 j = i1;
  113.                 store_lng = dn_k_per_user[i1];
  114.             }
  115. [PAUSE]               if( u.dk > store_lng )
  116.         {
  117.             dn_k_per_user[j] = u.dk;
  118.             strcpy( s[3][j], nam(&u, i ) );
  119.         }
  120.         store_flt = timeon_per_user[0];
  121.         j = 0;
  122.         for( i1=1; i1<10; i1++ )
  123.             if( timeon_per_user[i1] < store_flt )
  124.             {
  125.                 j = i1;
  126.                 store_flt = timeon_per_user[i1];
  127.             }
  128.         if( u.timeon > store_flt )
  129.         {
  130.             timeon_per_user[j] = u.timeon;
  131.             strcpy( s[4][j], nam(&u, i ) );
  132.         }
  133.     }
  134.  
  135. /* Fix the Timeon to minutes instead of seconds. */
  136.  
  137.     for( i=0; i < 10; i++ )
  138.         timeon_per_user[i] = ( timeon_per_user[i] / 60 );
  139. [PAUSE]       /*
  140.         Sort Data 
  141. */
  142.     for( j = 0; j < 10; j++ )
  143.         for( i = j+1; i < 10; i++ )
  144.         {
  145.             if( posts_per_user[i] > posts_per_user[j] )
  146.             {
  147.             store_int = posts_per_user[i];
  148.             posts_per_user[i] = posts_per_user[j];
  149.             posts_per_user[j] = store_int;
  150.             strcpy(store_chr, s[0][i]);
  151.             strcpy(s[0][i], s[0][j]);
  152.             strcpy(s[0][j], store_chr);
  153.            }
  154.            
  155.            if( logons_per_user[i] > logons_per_user[j] )
  156.            {
  157.             store_int = logons_per_user[i];
  158.             logons_per_user[i] = logons_per_user[j];
  159.             logons_per_user[j] = store_int;
  160.             strcpy(store_chr, s[1][i]);
  161.             strcpy(s[1][i], s[1][j]);
  162.             strcpy(s[1][j], store_chr);
  163. [PAUSE]                  }
  164.            
  165.            if( up_k_per_user[i] > up_k_per_user[j] )
  166.            {
  167.             store_lng = up_k_per_user[i];
  168.             up_k_per_user[i] = up_k_per_user[j];
  169.             up_k_per_user[j] = store_lng;
  170.             strcpy(store_chr, s[2][i]);
  171.             strcpy(s[2][i], s[2][j]);
  172.             strcpy(s[2][j], store_chr);
  173.            }
  174.            
  175.            if( dn_k_per_user[i] > dn_k_per_user[j] )
  176.            {
  177.             store_lng = dn_k_per_user[i];
  178.             dn_k_per_user[i] = dn_k_per_user[j];
  179.             dn_k_per_user[j] = store_lng;
  180.             strcpy(store_chr, s[3][i]);
  181.             strcpy(s[3][i], s[3][j]);
  182.             strcpy(s[3][j], store_chr);
  183.            }
  184.            
  185.            if( timeon_per_user[i] > timeon_per_user[j] )
  186.            {
  187. [PAUSE]                   store_flt = timeon_per_user[i];
  188.             timeon_per_user[i] = timeon_per_user[j];
  189.             timeon_per_user[j] = store_flt;
  190.             strcpy(store_chr, s[4][i]);
  191.             strcpy(s[4][i], s[4][j]);
  192.             strcpy(s[4][j], store_chr);
  193.            }
  194.         }          
  195.  
  196.     nl();
  197.     do {
  198.         npr("\r\nTop 10 Lists for %s!\r\n\n",syscfg.systemname);
  199.         prt(1,"1) Posts"); nl();
  200.         prt(2,"2) Logons"); nl();
  201.         prt(3,"3) K Uploaded"); nl();
  202.         prt(4,"4) K Downloaded"); nl();
  203.         prt(5,"5) Total Time on"); nl();
  204.         prt(6,"Q) Quit"); nl();nl();
  205.         prt(7,"Which (1-5,Q) ? ");
  206.         ch = onek("Q12345");
  207.         nl();
  208.         switch(ch) {
  209.             case 'Q':
  210.                 ok = 1;
  211. [PAUSE]                       break;
  212.             case '1':
  213.                 prt(3,"Highest number of posts");
  214.                 nl();nl();
  215.                 npr("##  Posts  Name\r\n");
  216.                 for (i = 0; i < 10; i++)
  217.                     npr("%2d. %-3d    %s\r\n",
  218.                         i+1,
  219.                         posts_per_user[i],
  220.                         s[0][i]);
  221.                 break;
  222.             case '2':
  223.                 prt(3,"Highest Number of Logons");
  224.                 nl();nl();
  225.                 npr("##  Logons  Name\r\n");
  226.                 for (i = 0; i < 10; i++)
  227.                     npr("%2d. %-3d    %s\r\n",
  228.                         i+1,
  229.                         logons_per_user[i],
  230.                         s[1][i]);
  231.                 break;
  232.             case '3':
  233.                 prt(3,"Most K Uploaded (Sledge's BEST)");
  234.                 nl();nl();
  235. [PAUSE]                       npr("##  Up K     Name\r\n");
  236.                 for (i = 0; i < 10; i++)
  237.                     npr("%2d. %-5ld    %s\r\n",
  238.                         i+1,
  239.                 up_k_per_user[i],
  240.                 s[2][i]);
  241.                 break;
  242.             case '4':
  243.                 prt(3,"Most K LEACHED");
  244.                 nl();nl();
  245.                 npr("##  Down K   Name\r\n");
  246.                 for (i = 0; i < 10; i++)
  247.                     npr("%2d. %-5ld    %s\r\n",
  248.                     i+1,
  249.                     dn_k_per_user[i],
  250.                     s[3][i]);
  251.                 break;
  252.             case '5':
  253.                 prt(3,"Most time spent online");
  254.                 nl();nl();
  255.                 npr("##  Time On   Name\r\n");
  256.                 for (i = 0; i < 10; i++)
  257.                     npr("%2d. %-6.0f    %s\r\n",
  258.                         i+1,
  259. [PAUSE]                               timeon_per_user[i],
  260.                         s[4][i]);
  261.                 break;
  262.         }
  263.     } while ((!hangup) && (!ok));
  264. }
  265.  
  266. STEP 2:
  267.  
  268. Add the following two lines in void mainmenu..
  269.  
  270.  
  271.   if ((strcmp(s,"UPLOAD")==0) && (actsl>10))
  272.     upload_post();
  273.   if (strcmp(s,"TOP10")==0)   /*add*/
  274.     top_ten_lists();          /*add*/
  275.  
  276.  
  277. STEP 3:
  278.  
  279. Add  //top10 to your menu and recompile!
  280.  
  281.  
  282.  
  283. [PAUSE]       Sub: MODS [for WWIV] ONLY [WWIVnet] 
  284. Message 200 of 200 (?=Help) ?